package commons.drawing;

import commons.ihm.ParametresAffichageCarto;
import commons.utils.primitive_geom.Point_d;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;


public class PointDrawable extends Point_d implements I_Drawable {

	double rayon_px;
	private Color borderColor, fillColor;

	public PointDrawable(Point_d ptCenter, double rayon_px, Color borderColor, Color fillColor) {
		this (ptCenter.x, ptCenter.y, rayon_px, borderColor, fillColor);
	}

	public PointDrawable(double x, double y, double rayon_px, Color borderColor, Color fillColor) {
		super(x, y);
		this.rayon_px = rayon_px;
		this.borderColor=borderColor;
		this.fillColor=fillColor;
	}

	public double getRayon() {return rayon_px;}

	public void draw(Graphics2D g, ParametresAffichageCarto pac) {

		g.setStroke(pac.getBasicStroke1());

		Ellipse2D.Float shRond = new Ellipse2D.Float();
		shRond.x = pac.x2X(getXMin());
		shRond.y = pac.y2Y(getYMax());
		shRond.width = (float) rayon_px*2;
		shRond.height = (float) rayon_px*2;

		if (fillColor != null) {
			g.setColor(fillColor);
			g.fill(shRond);
		}
		if (borderColor != null) {
			g.setColor(borderColor);
			g.draw(shRond);
		}
	}


	@Override
	public double distTo(Point_d pt) {
		return Math.abs(super.distTo(pt) - getRayon());
	}

	@Override
	public String getInfoBulle() {
		return super.toString();
	}

	@Override
	public String getInfoDetaillee() {
		return super.toString();
	}

}
